<?php

header('Access-Control-Allow-Origin: *');
include('../_inc/config.inc.php');

	
$_poi_name = $_GET['poi_name'];
$_poi_latitude = $_GET['poi_latitude'];
$_poi_longitude = $_GET['poi_longitude'];
$_poi_description = $_GET['poi_description'];

$data = array();
$data['error_code'] = 0;
$data['error_desc'] = '';
$data['result'] = array();

if( empty($_poi_name) || empty($_poi_latitude) || empty($_poi_longitude) || empty($_poi_description)){
	    $data['error_code'] = 2;
		$data['error_desc'] = 'Paramètre manquant';
		echo json_encode($data);
		exit();
}

// Exécution de la requête
$query = "INSERT INTO POI(poi_name, poi_latitude, poi_longitude, poi_description)
			VALUES('$_poi_name', '$_poi_latitude', '$_poi_longitude', '$_poi_description')
";
$result = mysql_query($query);


// Vérification du résultat
if (!$result) {
    $data['error_code'] = 1;
	$data['error_desc'] = 'Erreur sur la requête';
	echo json_encode($data);
	exit();
}

echo json_encode($data);
/*
if (isset($_GET['callback'])) echo $_GET['callback'].'('.$data.');'; 
else echo $data;*/